<fieldset>
	<legend> Utilisateurs </legend>
		<br/>
			<div id="champs">
				<?php
					if (isset($message)) {
						echo "<p>";
						echo $message;
						echo "</p>";
					} else {
						if (isset($tab['id_user'])) {
							$max = count($tab['id_user']);
							if (isset($_SESSION['droit'])) {
								echo "<TABLE BORDER=","1",">
										<CAPTION> Liste des utilisateurs : </CAPTION>
										<TR>
											<TH> Index </TH>
											<TH> Mail </TH>
											<TH> Civilite </TH>
											<TH> Nom </TH>
											<TH> Prenom </TH>
											<TH> Action </TH>
										</TR>";
								for($i=0 ; $i < $max ; $i++) {
									echo "<TR>";
									echo "<TD>", $tab['id_user'][$i], "</TD>";
									$mail=$tab['mail'][$i];
									echo "<TD>", "<a href=\"index.php?page=contact_user&mail_user=$mail\">", $tab['mail'][$i],"</a>", "</TD>";
									echo "<TD>", $tab['civilite'][$i], "</TD>";
									echo "<TD>", $tab['nom'][$i], "</TD>";
									echo "<TD>", $tab['prenom'][$i], "</TD>";
									$id = $tab['id_user'][$i];
									echo "<TD>";
									require_once("model/subscriptionBD.php");
									$user=view_subscriptionBD($tab['id_user'][$i]);
									if ($user == 0) {
										echo "<a href=\"index.php?page=add_subscriber&id_user=$id\">";
										echo "S'abonner";
									} else { 
										echo "<a href=\"index.php?page=delete_subscriber&id_user=$id\">";
										echo "Se desabonner";
									}
									echo "</a>";
									echo "<a href=\"index.php?page=fiche_user&id_user=$id\">";
									echo "<img src=\"./images/action/loupe.png\" title=\"Voir la fiche utilisateur\"/>";
									echo "</a>";
									echo "</TD>";
									echo "</TR>";
								}
							} 
							echo "</TABLE>";
						} else if (isset($tab['id_categ'])) {
							echo "<TABLE BORDER=","1",">
							<CAPTION> Liste des categories : </CAPTION>
							<TR>
								<TH> Index </TH>
								<TH> Nom </TH>
								<TH> Commentaire </TH>
								<TH> Action </TH>
							</TR>";
				
							$max = count($tab['id_categ']);
							for($i=0 ; $i < $max ; $i++) {
								echo "<TR>";
								echo "<TD>", $tab['id_categ'][$i], "</TD>";
								echo "<TD>", $tab['name_categ'][$i], "</TD>";
								echo "<TD>", $tab['comment_categ'][$i], "</TD>";
								if (isset($_SESSION['droit'])) {
									$id = $tab['id_categ'][$i];
									echo "<TD>";
									echo "<a href=\"index.php?page=view_category\">";
									echo "<img src=\"./images/action/loupe.png\"/>";
									echo "</a>";
									if($_SESSION['droit'] == 1) {
										echo "<a href=\"index.php?page=view_category&id_categ=$id\" onClick=\"affiche_cache('update_categ')\">";
										echo "<img src=\"./images/action/feuille.png\"/>";
										echo "</a>";
										echo "<a href=\"index.php?page=delete_category&id_categ=$id\">";
										echo "<img src=\"./images/action/croix.png\"/>";
										echo "</a>";
									}
								}
								echo "</TD>";
								echo "</TR>";
							} 
							echo "</TABLE>";
						} else if (isset($tab['id_tweet'])) {
							$max = count($tab['id_categ_tweet']);
						$count = 0;
						for($i=0 ; $i < $max ; $i++) {
							if (isset($_SESSION['id_user'])) {
								if(($_SESSION['id_user'] == $tab['id_user_tweet'][$i]) || (isset($_SESSION['droit']) && $_SESSION['droit'] == 1)) {
									$count++;
									if ($count == 1) {
										echo "<TABLE BORDER=","1",">
												<CAPTION> Liste des tweets : </CAPTION>
												<TR>
													<TH> Index </TH>
													<TH> Redacteur </TH>
													<TH> Categorie </TH>
													<TH> Texte </TH>
													<TH> Date publication </TH>
													<TH> Action </TH>
												</TR>";
									}
									echo "<TR>";
									echo "<TD>", $tab['id_tweet'][$i], "</TD>";
									require_once("model/userBD.php");
									$user=select_user_by_id($tab['id_user_tweet'][$i]);
									echo "<TD>", $user['nom'][0], " ", $user['prenom'][0], "</TD>";
									require_once("model/categoryBD.php");
									$categ=select_category_by_id($tab['id_categ_tweet'][$i]);
									echo "<TD>", $categ['name_categ'][0], "</TD>";
									echo "<TD>", $tab['text_tweet'][$i], "</TD>";
									echo "<TD>", $tab['date_tweet'][$i], "</TD>";
									$id = $tab['id_tweet'][$i];
									echo "<TD>";
									echo "<a href=\"index.php?page=view_tweet&id_tweet=$id\">";
									echo "<img src=\"./images/action/loupe.png\"/>";
									echo "</a>";
									echo "<a href=\"index.php?page=edit_tweet&id_tweet=$id\" onClick=\"affiche_cache('update_categ')\">";
									echo "<img src=\"./images/action/feuille.png\"/>";
									echo "</a>";
									echo "<a href=\"index.php?page=delete_tweet&id_tweet=$id\">";
									echo "<img src=\"./images/action/croix.png\"/>";
									echo "</a>";
									echo "</TD>";
									echo "</TR>";
								}
							}
						} 
						if ($count == 0)
							echo "<h3> Vous n'avez publier aucun tweet </h3>";
						else
							echo "</TABLE>";
						}
					}
				?>
			</div> <!-- fin div champs -->
</fieldset>